cd "/Users/dawnshen/Dropbox/Yinzhi/MassShootings/MassShootingsData/Merged"

*************************
*Figure 1 The percentage of Americans feeling sad during a lot the day yesterday
*************************

use "US_DAILY_working_analysisfile", clear
keep if year<=2016 & year>=2008
sum sadness year
mdesc sadness year

collapse (mean)sadness, by(date)
replace sadness=sadness*100

tsset date, daily
graph twoway tsline sadness, lcolor(black) tlabel(01jan2008 01jan2009 01jan2010 01jan2011 01jan2012 01jan2013 01jan2014 01jan2015 01jan2016 01jan2017, angle(horizontal) labsize(vsmall)) ylabel( ,angle(horizontal) labsize(vsmall)) ytitle("Sadness",size(small)) xtitle("Date",size(small)) graphregion(color(white))
graph export Figure1.pdf, replace


****************************
****************************
** Merged city
****************************
****************************

use "Merged_city_working_analysisfile", clear

*************************************************************************	
* Generate indicators of interview timing 
*************************************************************************	
drop if date==msdate //Drop obs if being interviewed on the MS day

gen bf28=0
replace bf28=1 if date-msdate>=-28 & date-msdate<=-1 //interviewed in the four weeks before the incident - control group
gen r_af1=0 //interviewed one day after the incident
replace r_af1=1 if date-msdate==1
gen bf28_1=0
replace bf28_1=1 if r_af1==1 | bf28==1  //interviewed one day after the incident or in the control group


foreach i in 2 4 7 14 21 28 {
gen r_af`i'=0
replace r_af`i'=1 if date-msdate>=`i'-1 & date-msdate<=`i'+1  //interviewed around i days after the incident

gen bf28_`i'=0
replace bf28_`i'=1 if bf28==1 | r_af`i'==1 //interviewed around i days after the incident or in the control group
replace bf28_`i'=. if date-msdate>0 & date-msdate<`i'-1 //remove those interviewed after MS and before i-1 days from the model
}

* # of respondents interviewed on the (i-1)th - (i+1)th day since MS: 23-91 obs
foreach i in 1 2 4 7 14 21 28 {
tab1 r_af`i', m
}


*************************************************************************
* Figure 2 The effect of mass shootings on daily emotions: three day average effect
*************************************************************************		
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow, fe i(cityid) level(90) 
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.5(0.1).5, labsize(vsmall) angle(horizontal)) groups(sadness_* = Sadness anger_* = Anger happy_* = Happy smile_* = Smile) yscale(range(-.5(0.1).5)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_3day_controls_byemotion.pdf, replace


	
*************************************************************************
* Figure 4 Effects of mass shootings by political affiliation: three day average effect
*************************************************************************		
foreach party in polrep poldem {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if `party'==1, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`party'", estimates)
matrix rownames emotion_`party' = `rownames'
matrix colnames emotion_`party' = Coef LL UL
matprint emotion_`party', d(3)
}

coefplot (matrix(emotion_poldem[,1]), ci((emotion_poldem[,2] emotion_poldem[,3])) msize(small) msymbol(circle) label("Democrat")) (matrix(emotion_polrep[,1]), ci((emotion_polrep[,2] emotion_polrep[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("Republican")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.8(0.1).8, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.8(0.1).8)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_3day_controls_byemotion_byparty.pdf, replace



*************************************************************************
* SI Figure S2 Respondent characteristics before and after mass shooting incidents
*************************************************************************	
*Standardize age, very different scale from every other variables
gen zage= (age-53.05538)/18.43714
sum zage

*Recode missing values to 0 in political affiliation
replace polrep=0 if polrep==.
replace poldem=0 if poldem==.

** Graph effect size by respondent characteristics

local rownames ""
mata: estimates = J(0,3,.)
foreach i in rwhite coll married female zage kids polrep poldem {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' i.year i.month i.dow, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.5(0.1).5, labsize(vsmall) angle(horizontal)) groups(rwhite* = White coll_* = College married_* = Married female_* = Female zage_*=Zage kids_* = Kids polrep_* = Rep poldem_* = Dem) yscale(range(-.5(0.1).5)) ///
xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28" 33 "day1" 34 "day2" 35 "day4" 36 "day7" 37 "day14" 38 "day21" 39 "day28" 41 "day1" 42 "day2" 43 "day4" 44 "day7" 45 "day14" 46 "day21" 47 "day28" 49 "day1" 50 "day2" 51 "day4" 52 "day7" 53 "day14" 54 "day21" 55 "day28" 57 "day1" 58 "day2" 59 "day4" 60 "day7" 61 "day14" 62 "day21" 63 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_respondent_chars.pdf, replace


*************************************************************************
* SI Figure S3 The trend in mood in the four weeks before and after a mass shooting
*************************************************************************	

* After measures being interviewed 1-28 days after the MS
gen after=0
replace after=1 if (date-msdate>=1) & (date-msdate<=28)
* Before measures being interviewed 1-28 days before the MS
gen before=0
replace before=1 if (date-msdate<=-1) & (date-msdate>=-28)
gen beforeafter=0
replace beforeafter=1 if before==1 | after==1
* Drop obs if being interviewed on the MS day
drop if date==msdate
* Generate # days since MS
gen difdate=date-msdate
gen dayssince=date-msdate 
replace dayssince=0 if msdate>=date
replace dayssince=0 if beforeafter==0
gen dayssincesq=dayssince*dayssince
gen dayssincecb=dayssince*dayssince*dayssince
* Generate # days before MS
gen daysbefore=date-msdate
replace daysbefore=0 if msdate<=date
replace daysbefore=0 if beforeafter==0


** Graph effect size 
foreach i in sadness anger happy smile {
local rownames ""
mata: estimates = J(0,1,.)

quietly xtreg `i' beforeafter after dayssince* daysbefore rwhite coll married female age i.kids i.year i.month i.dow, fe i(cityid) 
	matrix coef=r(table) 
	local beforeafter=coef[1,1]
	local daysbefore=coef[1,6]
	
foreach j in 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 {
	local day_`j'=`beforeafter'+`daysbefore'*`j'*(-1)
mata: estimates = estimates \ `day_`j''
            local rownames `rownames' `i'_bf`j'
}
mata: st_matrix("`i'_bf", estimates)
matrix rownames `i'_bf = `rownames'
matrix colnames `i'_bf = Effect
matprint `i'_bf, d(3)
}


foreach i in sadness anger happy smile  {
local rownames ""
mata: estimates = J(0,1,.)
	
quietly xtreg `i' beforeafter after dayssince* daysbefore rwhite coll married female age i.kids i.year i.month i.dow, fe i(cityid) 
	matrix coef=r(table)
	local beforeafter=coef[1,1]
	local after=coef[1,2]
	local dayssince=coef[1,3]
	local dayssincesq=coef[1,4]
	local dayssincecb=coef[1,5]
	
foreach j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 {
	local day_`j'=`beforeafter' + `after' + `dayssince'*`j' + `dayssincesq'*`j'*`j' + `dayssincecb'*`j'*`j'*`j'
mata: estimates = estimates \ `day_`j''
            local rownames `rownames' `i'_af`j'
}

mata: st_matrix("`i'_af", estimates)
matrix rownames `i'_af = `rownames'
matrix colnames `i'_af = Effect
matprint `i'_af, d(3)		
}


coefplot (matrix(sadness_bf[,1]), msize(tiny) lcolor(black) lpattern(solid)  lwidth(medthick) recast(line))  (matrix(sadness_af[,1]), msize(tiny)  lcolor(black) lpattern(solid)  lwidth(medthick)  recast(line)) ///
(matrix(anger_bf[,1]), msize(tiny) lcolor(black) lcolor(black) lpattern(solid) lwidth(medthick) recast(line) )  (matrix(anger_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line) ) ///
(matrix(happy_bf[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)) (matrix(happy_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)) ///
 (matrix(smile_bf[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line))  (matrix(smile_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)),  xline(39  116.5 193.5 271,lcolor(grey) lpattern(dash) lwidth(.3))  order(. sadness* . anger* . happy* . smile* .) graphregion(color(white)) vertical ytitle("Effect size",size(large)) ylabel(-.5(0.1).5, labsize(medium) angle(horizontal)) yscale(range(-.5(0.1).5))  xsize(10) ysize(3) ///
xlabel( 14 "-25" 19 "-20" 24 "-15" 29 "-10" 34 "-5" 39 "0" 44 "5" 49 "10" 54 "15" 59 "20" 64 "25" 91 "-25" 96.5 "-20" 101.5 "-15" 106.5 "-10" 111.5 "-5" 116.5 "0" 121.5 "5" 126.5 "10" 131.5 "15" 136.5 "20" 141.5 "25" 168.5 "-25" 173.5 "-20" 178.5 "-15" 183.5 "-10" 188.5 "-5" 193.5 "0" 198.5 "5" 203.5 "10" 208.5 "15" 213.5 "20" 218.5 "25" 246 "-25" 251 "-20" 256 "-15" 261 "-10" 266 "-5" 271 "0" 276 "5" 281 "10" 286 "15" 291 "20" 296 "25", ///
labsize(medium) angle(vertical) ) leg(off) groups(sadness_* = Sadness anger_* = Anger happy_* = Happy smile_* = Smile, gap(10) labsize(vlarge))
graph export Merged_city_daysince_controls_byemotion.pdf, replace


** Graph effect size by political affiliation
foreach party in polrep poldem {
foreach i in sadness anger happy smile {
local rownames ""
mata: estimates = J(0,1,.)

quietly xtreg `i' beforeafter after dayssince* daysbefore rwhite coll married female age i.kids i.year i.month i.dow if `party'==1, fe i(cityid)
	matrix coef=r(table) 
	local beforeafter=coef[1,1]
	local daysbefore=coef[1,6]
	
foreach j in 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 {
	local day_`j'=`beforeafter'+`daysbefore'*`j'*(-1)
mata: estimates = estimates \ `day_`j''
            local rownames `rownames' `i'_bf`j'
}
mata: st_matrix("`i'_bf", estimates)
matrix rownames `i'_bf = `rownames'
matrix colnames `i'_bf = Effect
matprint `i'_bf, d(3)
}


foreach i in sadness anger happy smile  {
local rownames ""
mata: estimates = J(0,1,.)
	
quietly xtreg `i' beforeafter after dayssince* daysbefore rwhite coll married female age i.kids i.year i.month i.dow if `party'==1, fe i(cityid)
	matrix coef=r(table)
	local beforeafter=coef[1,1]
	local after=coef[1,2]
	local dayssince=coef[1,3]
	local dayssincesq=coef[1,4]
	local dayssincecb=coef[1,5]
	
foreach j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 {
	local day_`j'=`beforeafter' + `after' + `dayssince'*`j' + `dayssincesq'*`j'*`j' + `dayssincecb'*`j'*`j'*`j'
mata: estimates = estimates \ `day_`j''
            local rownames `rownames' `i'_af`j'
}

mata: st_matrix("`i'_af", estimates)
matrix rownames `i'_af = `rownames'
matrix colnames `i'_af = Effect
matprint `i'_af, d(3)		
}


coefplot (matrix(sadness_bf[,1]), msize(tiny) lcolor(black) lpattern(solid)  lwidth(medthick) recast(line))  (matrix(sadness_af[,1]), msize(tiny)  lcolor(black) lpattern(solid)  lwidth(medthick)  recast(line)) ///
(matrix(anger_bf[,1]), msize(tiny) lcolor(black) lcolor(black) lpattern(solid) lwidth(medthick) recast(line) )  (matrix(anger_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line) ) ///
(matrix(happy_bf[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)) (matrix(happy_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)) ///
 (matrix(smile_bf[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line))  (matrix(smile_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)),  xline(39  116.5 193.5 271,lcolor(grey) lpattern(dash) lwidth(.3))  order(. sadness* . anger* . happy* . smile* .) graphregion(color(white)) vertical ytitle("Effect size",size(large)) ylabel(-1(0.1)1, labsize(small) angle(horizontal)) yscale(range(-1(0.1)1))  xsize(10) ysize(3) ///
xlabel( 14 "-25" 19 "-20" 24 "-15" 29 "-10" 34 "-5" 39 "0" 44 "5" 49 "10" 54 "15" 59 "20" 64 "25" 91 "-25" 96.5 "-20" 101.5 "-15" 106.5 "-10" 111.5 "-5" 116.5 "0" 121.5 "5" 126.5 "10" 131.5 "15" 136.5 "20" 141.5 "25" 168.5 "-25" 173.5 "-20" 178.5 "-15" 183.5 "-10" 188.5 "-5" 193.5 "0" 198.5 "5" 203.5 "10" 208.5 "15" 213.5 "20" 218.5 "25" 246 "-25" 251 "-20" 256 "-15" 261 "-10" 266 "-5" 271 "0" 276 "5" 281 "10" 286 "15" 291 "20" 296 "25", ///
labsize(medium) angle(vertical) ) leg(off) groups(sadness_* = Sadness anger_* = Anger happy_* = Happy smile_* = Smile, gap(10) labsize(vlarge))

graph export Merged_city_daysince_controls_byemotion_`party'.pdf, replace

}





*************************************************************************
* SI Figure S5 Effects by respondent race: three day average effect
*************************************************************************		
mdesc rblack rwhite   //2.56% missing	
* # interviewed around i day after MS
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if rblack==1
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if rwhite==1

foreach race in rblack rwhite {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' coll married female age i.kids i.year i.month i.dow if `race'==1, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`race'", estimates)
matrix rownames emotion_`race' = `rownames'
matrix colnames emotion_`race' = Coef LL UL
matprint emotion_`race', d(3)
}

coefplot (matrix(emotion_rblack[,1]), ci((emotion_rblack[,2] emotion_rblack[,3])) msize(small) msymbol(circle) label("Black respondents")) (matrix(emotion_rwhite[,1]), ci((emotion_rwhite[,2] emotion_rwhite[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("White respondents")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-1(0.1)1, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.8(0.1).8)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_3day_controls_byemotion_byrace.pdf, replace


*************************************************************************
* SI Figure S6 Effects by gender: three day average effect
*************************************************************************		
mdesc female    //.00% missing	
gen male = female*(-1)+1
tab female male
* # interviewed around i day after MS
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if female==1
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if male==1

foreach gender in female male {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married age i.kids i.year i.month i.dow if `gender'==1, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`gender'", estimates)
matrix rownames emotion_`gender' = `rownames'
matrix colnames emotion_`gender' = Coef LL UL
matprint emotion_`gender', d(3)
}

coefplot (matrix(emotion_female[,1]), ci((emotion_female[,2] emotion_female[,3])) msize(small) msymbol(circle) label("Female")) (matrix(emotion_male[,1]), ci((emotion_male[,2] emotion_male[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("Male")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.8(0.1).8, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.8(0.1).8)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_3day_controls_byemotion_bygender.pdf, replace



*************************************************************************
* SI Figure S7 Selecting deadliest incidents : three day average effect
*************************************************************************		
tab1 Number_Killed,m    //0% missing

local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if Number_Killed>=10, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)


coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.5(0.1).5, labsize(vsmall) angle(horizontal)) groups(sadness_* = Sadness anger_* = Anger happy_* = Happy smile_* = Smile) yscale(range(-.5(0.1).5)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_3day_controls_byemotion_over10deaths.pdf, replace


*************************************************************************
* SI Figure S8 Effects by shooter race: three day average effect
*************************************************************************
tab ShooterRace, m
* # interviewed around i day after MS
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if ShooterRace=="White American or European American" 
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if ShooterRace=="Black American or African American" 

* Generate shooter race
gen shooter_white=0
replace shooter_white=1 if ShooterRace=="White American or European American"
gen shooter_black=0
replace shooter_black=1 if ShooterRace=="Black American or African American"

foreach race in shooter_black shooter_white {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if `race'==1, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`race'", estimates)
matrix rownames emotion_`race' = `rownames'
matrix colnames emotion_`race' = Coef LL UL
matprint emotion_`race', d(3)
}

coefplot (matrix(emotion_shooter_black[,1]), ci((emotion_shooter_black[,2] emotion_shooter_black[,3])) msize(small) msymbol(circle) label("Black shooter")) (matrix(emotion_shooter_white[,1]), ci((emotion_shooter_white[,2] emotion_shooter_white[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("White shooter")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-1(0.1)1, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-1(0.1)1)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_3day_controls_byemotion_byshooterrace.pdf, replace


********************************************************************************************************
* SI Figure S1 The effect of the relative timing of the interview and mass shooting on the number of interviews conducted
********************************************************************************************************
*generate # of interviews by day
gen count=1
collapse (sum) count (firstnm) bf28-bf28_28 year month dow msdate, by(cityid date)


local rownames ""
mata: estimates = J(0,3,.)

  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg count r_af`j' bf28_`j' i.year i.month i.dow, fe i(cityid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' count_`j'
    }
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-1(0.1)1, labsize(vsmall) angle(horizontal)) yscale(range(-.08(0.01).08)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" , labsize(vsmall) angle(vertical) )  
graph export Merged_citybfaf_interviewscounts.pdf, replace


****************************		
****************************
** Merged state
****************************
****************************

use "Merged_state_working_analysisfile", clear
*************************************************************************	
* Generate indicators of interview timing 
*************************************************************************	
drop if date==msdate //Drop obs if being interviewed on the MS day

gen bf28=0
replace bf28=1 if date-msdate>=-28 & date-msdate<=-1 //interviewed in the four weeks before the incident - control group
gen r_af1=0 //interviewed one day after the incident
replace r_af1=1 if date-msdate==1
gen bf28_1=0
replace bf28_1=1 if r_af1==1 | bf28==1  //interviewed one day after the incident or in the control group

foreach i in 2 4 7 14 21 28 {
gen r_af`i'=0
replace r_af`i'=1 if date-msdate>=`i'-1 & date-msdate<=`i'+1  //interviewed around i days after the incident

gen bf28_`i'=0
replace bf28_`i'=1 if bf28==1 | r_af`i'==1 //interviewed around i days after the incident or in the control group
replace bf28_`i'=. if date-msdate>0 & date-msdate<`i'-1 //remove those interviewed after MS and before i-1 days from the model

}

* # of respondents interviewed on the (i-1)th - (i+1)th day since MS: 23-91 obs
foreach i in 1 2 4 7 14 21 28 {
tab1 r_af`i', m
}


*************************************************************************
* Figure 3 The effect of mass shootings on daily emotions: three day average effect
*************************************************************************	
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow, fe i(stateid) level(90) 
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.05(0.01).05, labsize(vsmall) angle(horizontal)) groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.05(0.01).05)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_3day_controls_byemotion.pdf, replace


*************************************************************************
* SI Figure S2 Respondent characteristics before and after mass shooting incidents
*************************************************************************
*Respondent characteristics
sum rwhite coll married female age kids polrep poldem
mdesc rwhite coll married female age kids polrep poldem

*Standardize age, very different scale from every other variables
gen zage= (age-53.85609)/18.01558
sum zage

*Recode missing values to 0 in political affiliation
replace polrep=0 if polrep==.
replace poldem=0 if poldem==.


** Graph effect size by respondent characteristics
local rownames ""
mata: estimates = J(0,3,.)
foreach i in rwhite coll married female zage kids polrep poldem {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' i.year i.month i.dow, fe i(stateid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.1(0.02).1, labsize(vsmall) angle(horizontal)) groups(rwhite* = White coll_* = College married_* = Married female_* = Female zage_*=Zage kids_* = Kids polrep_* = Rep poldem_* = Dem) yscale(range(-.1(0.02).1)) ///
xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28" 33 "day1" 34 "day2" 35 "day4" 36 "day7" 37 "day14" 38 "day21" 39 "day28" 41 "day1" 42 "day2" 43 "day4" 44 "day7" 45 "day14" 46 "day21" 47 "day28" 49 "day1" 50 "day2" 51 "day4" 52 "day7" 53 "day14" 54 "day21" 55 "day28" 57 "day1" 58 "day2" 59 "day4" 60 "day7" 61 "day14" 62 "day21" 63 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_respondent_chars.pdf, replace



*************************************************************************
* SI Figure S3 The trend in mood in the four weeks before and after a mass shooting
*************************************************************************	

gen after=0
replace after=1 if (date-msdate>=1) & (date-msdate<=28)
gen before=0
replace before=1 if (date-msdate<=-1) & (date-msdate>=-28)
gen beforeafter=0
replace beforeafter=1 if before==1 | after==1
drop if date==msdate
gen difdate=date-msdate
gen dayssince=date-msdate 
replace dayssince=0 if msdate>=date
replace dayssince=0 if beforeafter==0
gen dayssincesq=dayssince*dayssince
gen dayssincecb=dayssince*dayssince*dayssince
gen daysbefore=date-msdate
replace daysbefore=0 if msdate<=date
replace daysbefore=0 if beforeafter==0

		
	
** Graph effect size 

foreach i in sadness anger happy smile {
local rownames ""
mata: estimates = J(0,1,.)

quietly xtreg `i' beforeafter after dayssince* daysbefore rwhite coll married female age i.kids i.year i.month i.dow, fe i(stateid) 
	matrix coef=r(table) 
	local beforeafter=coef[1,1]
	local daysbefore=coef[1,6]
	
foreach j in 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 {
	local day_`j'=`beforeafter'+`daysbefore'*`j'*(-1)
mata: estimates = estimates \ `day_`j''
            local rownames `rownames' `i'_bf`j'
}
mata: st_matrix("`i'_bf", estimates)
matrix rownames `i'_bf = `rownames'
matrix colnames `i'_bf = Effect
matprint `i'_bf, d(3)
}


foreach i in sadness anger happy smile  {
local rownames ""
mata: estimates = J(0,1,.)
	
quietly xtreg `i' beforeafter after dayssince* daysbefore rwhite coll married female age i.kids i.year i.month i.dow, fe i(stateid)
	matrix coef=r(table)
	local beforeafter=coef[1,1]
	local after=coef[1,2]
	local dayssince=coef[1,3]
	local dayssincesq=coef[1,4]
	local dayssincecb=coef[1,5]
	
foreach j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 {
	local day_`j'=`beforeafter' + `after' + `dayssince'*`j' + `dayssincesq'*`j'*`j' + `dayssincecb'*`j'*`j'*`j'
mata: estimates = estimates \ `day_`j''
            local rownames `rownames' `i'_af`j'
}

mata: st_matrix("`i'_af", estimates)
matrix rownames `i'_af = `rownames'
matrix colnames `i'_af = Effect
matprint `i'_af, d(3)		
}


coefplot (matrix(sadness_bf[,1]), msize(tiny) lcolor(black) lpattern(solid)  lwidth(medthick) recast(line))  (matrix(sadness_af[,1]), msize(tiny)  lcolor(black) lpattern(solid)  lwidth(medthick)  recast(line)) ///
(matrix(anger_bf[,1]), msize(tiny) lcolor(black) lcolor(black) lpattern(solid) lwidth(medthick) recast(line) )  (matrix(anger_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line) ) ///
(matrix(happy_bf[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)) (matrix(happy_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)) ///
 (matrix(smile_bf[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line))  (matrix(smile_af[,1]), msize(tiny) lcolor(black) lpattern(solid) lwidth(medthick) recast(line)),  xline(39  116.5 193.5 271,lcolor(grey) lpattern(dash) lwidth(.3))  order(. sadness* . anger* . happy* . smile* .) graphregion(color(white)) vertical ytitle("Effect size",size(large)) ylabel(-.05(0.01).05, labsize(small) angle(horizontal)) yscale(range(-.05(0.01).05))  xsize(10) ysize(3) ///
xlabel( 14 "-25" 19 "-20" 24 "-15" 29 "-10" 34 "-5" 39 "0" 44 "5" 49 "10" 54 "15" 59 "20" 64 "25" 91 "-25" 96.5 "-20" 101.5 "-15" 106.5 "-10" 111.5 "-5" 116.5 "0" 121.5 "5" 126.5 "10" 131.5 "15" 136.5 "20" 141.5 "25" 168.5 "-25" 173.5 "-20" 178.5 "-15" 183.5 "-10" 188.5 "-5" 193.5 "0" 198.5 "5" 203.5 "10" 208.5 "15" 213.5 "20" 218.5 "25" 246 "-25" 251 "-20" 256 "-15" 261 "-10" 266 "-5" 271 "0" 276 "5" 281 "10" 286 "15" 291 "20" 296 "25", ///
labsize(medium) angle(vertical) ) leg(off) groups(sadness_* = Sadness anger_* = Anger happy_* = Happy smile_* = Smile, gap(10) labsize(vlarge))
graph export Merged_state_daysince_controls_byemotion.pdf, replace

	

*************************************************************************
* SI Figure S5 Effects by respondent race: three day average effect
*************************************************************************		
mdesc rblack rwhite   //2.56% missing	
* # interviewed around i day after MS
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if rblack==1
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if rwhite==1

foreach race in rblack rwhite {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' coll married female age i.kids i.year i.month i.dow if `race'==1, fe i(stateid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`race'", estimates)
matrix rownames emotion_`race' = `rownames'
matrix colnames emotion_`race' = Coef LL UL
matprint emotion_`race', d(3)
}

coefplot (matrix(emotion_rblack[,1]), ci((emotion_rblack[,2] emotion_rblack[,3])) msize(small) msymbol(circle) label("Black respondents")) (matrix(emotion_rwhite[,1]), ci((emotion_rwhite[,2] emotion_rwhite[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("White respondents")) , yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.2(0.02).2, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.2(0.02).2)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_3day_controls_byemotion_byrace.pdf, replace



*************************************************************************
* SI Figure S6 Effects by gender : three day average effect
*************************************************************************
mdesc female    //.00% missing	
gen male = female*(-1)+1
tab female male
		
foreach gender in female male {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married age i.kids i.year i.month i.dow if `gender'==1, fe i(stateid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`gender'", estimates)
matrix rownames emotion_`gender' = `rownames'
matrix colnames emotion_`gender' = Coef LL UL
matprint emotion_`gender', d(3)
}

coefplot (matrix(emotion_female[,1]), ci((emotion_female[,2] emotion_female[,3])) msize(small) msymbol(circle) label("Female")) (matrix(emotion_male[,1]), ci((emotion_male[,2] emotion_male[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("Male")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.08(0.01).08, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.08(0.01).08)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_3day_controls_byemotion_bygender.pdf, replace


*************************************************************************
* SI Figure S7 Selecting deadliest incidents : three day average effect
*************************************************************************
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if Number_Killed >= 10, fe i(stateid) level(90) 
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.15(0.01).15, labsize(vsmall) angle(horizontal)) groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.15(0.01).15)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_3day_controls_byemotion_over10deaths.pdf, replace

*************************************************************************
* SI Figure S8 Effects by shooter race: three day average effects
*************************************************************************
tab ShooterRace, m
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if ShooterRace=="White American or European American" 
tab1 r_af1 r_af2 r_af4 r_af7 r_af14 r_af21 r_af28 if ShooterRace=="Black American or African American" 

* Generate shooter race
gen shooter_white=0
replace shooter_white=1 if ShooterRace=="White American or European American"
gen shooter_black=0
replace shooter_black=1 if ShooterRace=="Black American or African American"


** Graph effect size by shooter race
foreach race in shooter_black shooter_white {
local rownames ""
mata: estimates = J(0,3,.)
foreach i in sadness anger happy smile {
  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg `i' r_af`j' bf28_`j' rwhite coll married female age i.kids i.year i.month i.dow if `race'==1, fe i(stateid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' `i'_`j'
    }
	}
mata: st_matrix("emotion_`race'", estimates)
matrix rownames emotion_`race' = `rownames'
matrix colnames emotion_`race' = Coef LL UL
matprint emotion_`race', d(3)
}

coefplot (matrix(emotion_shooter_black[,1]), ci((emotion_shooter_black[,2] emotion_shooter_black[,3])) msize(small) msymbol(circle) label("Black shooter")) (matrix(emotion_shooter_white[,1]), ci((emotion_shooter_white[,2] emotion_shooter_white[,3])) msize(small) msymbol(diamond) ciopts(lpattern(dash)) label("White shooter")), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-.2(0.02).2, labsize(vsmall) angle(horizontal)) ///
groups(sadness_* = Sadness anger_* = Anger worry_* = Worry happy_* = Happy smile_* = Smile) yscale(range(-.2(0.02).2)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" 9 "day1" 10 "day2" 11 "day4" 12 "day7" 13 "day14" 14 "day21" 15 "day28" 17 "day1" 18 "day2" 19 "day4" 20 "day7" 21 "day14" 22 "day21" 23 "day28" 25 "day1" 26 "day2" 27 "day4" 28 "day7" 29 "day14" 30 "day21" 31 "day28", labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_3day_controls_byemotion_byshooterrace.pdf, replace



********************************************************************************************************
* SI Figure S1 The effect of the relative timing of the interview and mass shooting on the number of interviews conducted
********************************************************************************************************
*generate # of interviews by day
gen count=1
collapse (sum) count (firstnm) bf28-bf28_28 year month dow msdate, by(stateid date)

local rownames ""
mata: estimates = J(0,3,.)

  foreach j in 1 2 4 7 14 21 28 {  
	        quietly xtreg count r_af`j' bf28_`j' i.year i.month i.dow, fe i(stateid) level(90)
            mata: estimates = estimates \ st_matrix("r(table)")'[1, (1,5,6)]
            local rownames `rownames' count_`j'
    }
mata: st_matrix("emotion", estimates)
matrix rownames emotion = `rownames'
matrix colnames emotion = Coef LL UL
matprint emotion, d(3)

coefplot (matrix(emotion[,1]), ci((emotion[,2] emotion[,3])) msize(small) mcolor(black)), yline(0,lcolor(grey) lpattern(dash) lwidth(.3)) graphregion(color(white)) vertical ytitle("Effect size",size(small)) ylabel(-10(2)10, labsize(vsmall) angle(horizontal)) yscale(range(-10(2)10)) xlabel(1 "day1" 2 "day2" 3 "day4" 4 "day7" 5 "day14" 6 "day21" 7 "day28" , labsize(vsmall) angle(vertical) )  
graph export Merged_statebfaf_interviewscounts.pdf, replace





